﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MallInteractiveMap.CMSWebClient.Common;
using MallInteractiveMap.CMSWebClient.Presenter;
using MallInteractiveMap.Language;

namespace MallInteractiveMap.CMSWebClient.Account
{
    public partial class ChangePassword : BasePage
    {
        private UserPresenter _presenter;
        protected void Page_Load(object sender, EventArgs e)
        {
            _presenter = new UserPresenter();
        }

        protected void ChangePasswordPushButton_Click(object sender, EventArgs e)
        {
            if (_presenter.ChangedPassword(CurrentPassword.Text, NewPassword.Text, HttpContext.Current.User.Identity.Name))
            {
                ShowMessage(LanguageLoader.GetText("PASSWORD_CHANGED_SUCCESS"), "Success");
            }
            else
            {
                ShowMessage(LanguageLoader.GetText("FAILED_OPERATION_MESSAGE"), LanguageLoader.GetText("FAILED"));
            }
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            CurrentPasswordLabel.Text = LanguageLoader.GetText("OLD_PASSWORD");
            NewPasswordLabel.Text = LanguageLoader.GetText("OLD_PASSWORD");
            ConfirmNewPasswordLabel.Text = LanguageLoader.GetText("CONFIRM_NEW_PASSWORD");
            ChangePasswordPushButton.Text = LanguageLoader.GetText("CHANGE_PASSWORD");
            CurrentPasswordRequired.ToolTip = CurrentPasswordRequired.ErrorMessage = LanguageLoader.GetText("OLD_PASSWORD_REQUIRED");
            NewPasswordRequired.ToolTip = NewPasswordRequired.ErrorMessage = LanguageLoader.GetText("NEW_PASSWORD_REQUIRED");
            ConfirmNewPasswordRequired.ToolTip = ConfirmNewPasswordRequired.ErrorMessage = LanguageLoader.GetText("CONFIRM_NEW_PASSWORD_REQUIRED");
            NewPasswordCompare.ToolTip = NewPasswordCompare.ErrorMessage = LanguageLoader.GetText("COMPARE_PASSWORD_ERROR");
        }
    }
}
